using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Scalextric
{
    public class PB6RecievedPackage
    {
        public HandsetTrackStatus HandsetTrackStatus { get; set; }
        public DriverHandset DrivePacket1 { get; set; }
        public DriverHandset DrivePacket2 { get; set; }
        public DriverHandset DrivePacket3 { get; set; }
        public DriverHandset DrivePacket4 { get; set; }
        public DriverHandset DrivePacket5 { get; set; }
        public DriverHandset DrivePacket6 { get; set; }
        public AuxPortCurrent AuxPortCurrent { get; set; }
        public CarIDTrackUpdate CarIDTrackUpdate { get; set; }
        public GameTime GameTime { get; set; }
        public ButtonStatus ButtonStatus { get; set; }
        public Checksum Checksum { get; set; }

        public PB6RecievedPackage(byte[] data)
        {
            if (data.Length != 15)
                throw new Exception();
            HandsetTrackStatus = new HandsetTrackStatus(data[0]);
            DrivePacket1 = new DriverHandset(data[1]);
            DrivePacket2 = new DriverHandset(data[2]);
            DrivePacket3 = new DriverHandset(data[3]);
            DrivePacket4 = new DriverHandset(data[4]);
            DrivePacket5 = new DriverHandset(data[5]);
            DrivePacket6 = new DriverHandset(data[6]);
            AuxPortCurrent = new AuxPortCurrent(data[7]);
            CarIDTrackUpdate = new CarIDTrackUpdate(data[8]);
            byte[] gData = new byte[4];
            for (int i = 0; i < 4; i++)
            {
                gData[i] = data[i + 9];
            }
            GameTime = new GameTime(gData);
            Checksum = new Checksum(data);
        }
    }
}
